package org.arch_learn.mvc.pojo;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * 封装handler相关信息
 */
public class Handler {
    private Object controllerObj;
    private Method method;
    //url正则
    private Pattern pattern;
    //参数顺序，是为了进行参数绑定。key是参数名，value是参数索引（第几个参数）
    private Map<String,Integer> paramIndexMapping;

    public Handler(Object controllerObj, Method method, Pattern pattern) {
        this.controllerObj = controllerObj;
        this.method = method;
        this.pattern = pattern;
        this.paramIndexMapping = new HashMap<>();
    }

    public Object getControllerObj() {
        return controllerObj;
    }

    public void setControllerObj(Object controllerObj) {
        this.controllerObj = controllerObj;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public Pattern getPattern() {
        return pattern;
    }

    public void setPattern(Pattern pattern) {
        this.pattern = pattern;
    }

    public Map<String, Integer> getParamIndexMapping() {
        return paramIndexMapping;
    }

    public void setParamIndexMapping(Map<String, Integer> paramIndexMapping) {
        this.paramIndexMapping = paramIndexMapping;
    }
}
